package com.epfresh.supplier.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangzhanghuan
 * @version 1.0
 * @date create 17-12-18
 * @Description
 */

public class GrouponList {


    List<GrouponListItem> grouponList;
    int currentPage;

    public int getGrouponListSize(){
        return grouponList != null?grouponList.size():0;
    }
    public List<GrouponListItem> getGrouponList() {
        return grouponList;
    }

    public void setGrouponList(List<GrouponListItem> grouponList) {
        this.grouponList = grouponList;
    }

    public List<GrouponListItem> getNextList() {
        if (grouponList != null && grouponList.size() > 0) {
            int size = grouponList.size();
            int p = size / 3 + (size % 3 > 0 ? 1 : 0);
            List<GrouponListItem> list = new ArrayList<>();
            if (currentPage < p) {

            } else {
                currentPage = 0;
            }
            int startIndex = currentPage * 3;
            int endIndex = startIndex + 3;
            for (int i = startIndex; i < endIndex; i++) {
                if (i < size) {
                    list.add(grouponList.get(i));
                } else {
                    break;
                }
            }

            currentPage++;
            return list;
        }

        return null;
    }

}
